<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>标签 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/tag/tag.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 标签</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>🏷️ 标签演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item">
                        <h3>基础标签</h3>
                        <div id="basicTag"></div>
                    </div>

                    <div class="demo-item">
                        <h3>不同类型</h3>
                        <div id="typeTag"></div>
                    </div>

                    <div class="demo-item">
                        <h3>不同大小</h3>
                        <div id="sizeTag"></div>
                    </div>

                    <div class="demo-item">
                        <h3>带图标</h3>
                        <div id="iconTag"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>标签输入框</h3>
                        <div id="tagInput"></div>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/tag/tag.css"&gt;
&lt;script src="components/tag/tag.js"&lt;/script&gt;

// 2. 创建容器
&lt;div id="tagContainer"&lt;/div&gt;

// 3. 初始化标签组件
const tag = new Tag({
    container: '#tagContainer',
    tags: ['标签1', '标签2', '标签3'],
    type: 'primary',
    closable: true,
    onClose: (result) => {
        console.log('关闭标签:', result.tag);
    }
});

// 4. 添加标签
tag.addTag('新标签');

// 5. 获取标签列表
const tags = tag.getTags();</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/tag/tag.js"></script>
    <script>
        // 基础标签
        const basicTag = new Tag({
            container: '#basicTag',
            tags: ['JavaScript', 'Python', 'Java', 'Go', 'Rust'],
            closable: true
        });

        // 不同类型
        const typeTag = new Tag({
            container: '#typeTag',
            tags: [
                { label: '默认', type: 'default' },
                { label: '主色', type: 'primary' },
                { label: '成功', type: 'success' },
                { label: '警告', type: 'warning' },
                { label: '错误', type: 'error' },
                { label: '信息', type: 'info' }
            ],
            closable: false
        });

        // 不同大小
        const sizeTag = new Tag({
            container: '#sizeTag',
            tags: [
                { label: '小', size: 'small' },
                { label: '中', size: 'medium' },
                { label: '大', size: 'large' }
            ],
            type: 'primary',
            closable: false
        });

        // 带图标
        const iconTag = new Tag({
            container: '#iconTag',
            tags: [
                { label: 'JavaScript', icon: '📜' },
                { label: 'Python', icon: '🐍' },
                { label: 'Java', icon: '☕' },
                { label: 'Go', icon: '🐹' },
                { label: 'Rust', icon: '🦀' }
            ],
            type: 'primary',
            closable: true
        });

        // 标签输入框
        const tagInput = new TagInput({
            container: '#tagInput',
            placeholder: '输入标签后按 Enter',
            maxTags: 8,
            onTagAdd: (result) => {
                console.log('添加标签:', result.tag);
            },
            onTagRemove: (result) => {
                console.log('删除标签:', result.tag);
            }
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 16px;
            color: var(--text-primary);
        }

        .demo-item > div {
            margin-bottom: 12px;
            overflow: visible;
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: 1fr;
            }
        }
    </style>
</body>
</html>
